home *** CD-ROM | disk | FTP | other *** search
- .Na "bcp_colfmt"
- .mc |
- .Aa
- .Fu
- Specify the format of a host file for bulk copy purposes.
- .Ih "bcp, specify the host file format"
- .Sy
- .Sf "RETCODE bcp_colfmt (dbproc, host_colnum, host_type,"
- .sp -1v
- .Sf " host_prefixlen, host_collen, host_term,"
- .sp -1v
- .Sf " host_termlen, table_colnum)"
- .Sp "DBPROCESS" "*dbproc"
- .Sp "int" "host_colnum"
- .Sp "int" "host_type"
- .Sp "int" "host_prefixlen"
- .Sp "DBINT" "host_collen"
- .Sp "BYTE" "*host_term"
- .Sp "int" "host_termlen"
- .Sp "int" "table_colnum"
- .Co
- .Bl
- \f2bcp_colfmt()\f1 allows you to specify the host file format for bulk copies.
- For bulk copy purposes, a format contains the following parts:
- .in +5n
- .Bl *
- A mapping from host file columns to database columns.
- .Bl *
- The datatype of each host file column.
- .Bl *
- The length of the optional length prefix of each column.
- .Bl *
- The maximum length of the host file column's data.
- .Bl *
- The optional terminating byte sequence for each column.
- .Bl *
- The length of this optional terminating byte sequence.
- .in -5n
- .Bl
- Each call to \f2bcp_colfmt()\f1 specifies the format for one host file
- column. For example, if you have a table with five columns, and want to
- change the default settings for three of those columns, you should
- first call \f2bcp_columns(dbproc, 5)\f1, and then call \f2bcp_colfmt()\f1 five times,
- with three of those calls setting your custom format.
- The remaining two calls should have their \f2host_type\f1 set to 0, and their
- \f2host_prefixlen\f1, \f2host_collen\f1, and \f2host_termlen\f1 parameters set to -1.
- The result of this would be to copy all five columns\(emthree with your
- customized format and two with the default format.
- .Bl
- \f2bcp_columns()\f1 \f2must\f1 be called before any calls to \f2bcp_colfmt()\f1.
- .Bl
- You \f2must\f1 call \f2bcp_colfmt()\f1 for every column in the host file,
- regardless of whether some of those columns use the default format
- or are skipped.
- .Bl
- To skip a column, set the \f2table_column\f1 parameter to 0.
- .Bl
- For information on the \f2bcp\f1 utility program, see its manual page
- in the \f2Commands Reference\f1.
- .Bz
- .Pa
- .Pi dbproc
- A pointer to the DBPROCESS structure that provides the connection
- for a particular front-end/\*S process. It contains all the
- information that \*L uses to manage communications and data between the
- front end and \*S.
- .Pi host_colnum
- The column in the host file whose format is being specified.
- The first column is number 1.
- .Pi host_type
- The datatype of this column in the host file, expressed as a \*S datatype.
- If it is different from the datatype of the corresponding column
- in the database table (\f2table_colnum\f1), the conversion will
- be performed automatically.
- See the \f2dbconvert()\f1 manual page
- for a table of allowable data conversions.
- That manual page also contains a list of \*S datatypes.
- .sp 0.5v
- If you want to specify the same datatype as in the corresponding
- column of the database table (\f2table_colnum\f1), this parameter
- should be set to 0.
- .Pi host_prefixlen
- The length of the length prefix for this column in the
- host file.
- Legal prefix lengths are
- 1, 2, and 4 bytes. To avoid using a length prefix, this
- parameter should be set to 0. To let \f2bcp\f1 decide whether
- to use a length prefix,
- this parameter should be set to -1.
- In such a case, \f2bcp\f1 will use a length prefix (of whatever length is necessary)
- if the database column length is variable.
- .sp 0.5v
- If more than one means of specifying a host file column length
- is used (such as a length prefix and a maximum column length,
- or a length prefix and a terminator sequence), \f2bcp\f1 will look at
- all of them and use the one that results in the shortest amount
- of data being copied.
- .sp 0.5v
- One valuable use for length prefixes is to simplify the specifying
- of null data values in a host file.
- For instance, assume you have a 1-byte length prefix for a 4-byte integer column.
- Ordinarily, the length prefix will contain a value of 4, to indicate that
- a 4-byte value follows.
- However, if the value of the column is null, the length prefix can be set to 0,
- to indicate that 0 bytes follow for the column.
- .Pi host_collen
- The maximum length of this column's data in the host file,
- \f2not\f1 including the length of any length prefix and/or terminator.
- Setting \f2host_collen\f1 to 0 signifies that the data is null.
- Setting \f2host_collen\f1 to -1 indicates that the system should ignore
- this parameter (\f2i.e.,\f1 there is no default maximum length).
- .sp 0.5v
- For fixed-length datatypes, such as integers,
- the length of the data is constant, except for the special case of null values.
- Therefore, for fixed-length datatypes, \f2host_collen\f1 must always
- be -1, except when the data is null, in which case \f2host_collen\f1
- must be 0.
- .sp 0.5v
- For character, text, binary, and image data, \f2host_collen\f1 can be
- -1, 0, or some positive value.
- If \f2host_collen\f1 is -1, the system will use either a length prefix
- or a terminator sequence to determine the length of the data.
- (If both are supplied, the system will use the one that results in
- the shortest amount of data being copied.)
- If \f2host_collen\f1 is -1 and neither a prefix length nor a
- terminator sequence is specified, the system will return an error message.
- If \f2host_collen\f1 is 0, the system assumes the data is null.
- If \f2host_collen\f1 is some positive value, the system uses \f2host_collen\f1 as
- the maximum data length.
- However, if, in addition to a positive \f2host_collen\f1,
- a prefix length and/or terminator sequence is provided,
- the system determines the data length by using the method
- that results in the shortest amount of data being copied.
- .Pi host_term
- The terminator sequence to be used for this column.
- This parameter is mainly useful for character, text, binary, and image data
- types, because all other types are of fixed length.
- To avoid using a terminator, set this parameter to NULL.
- To set the terminator to the NULL character, set \f2host_term\f1 to "\\0".
- To make the tab character the terminator, set \f2host_term\f1 to
- "\\t".
- To make the newline character the terminator, set
- \f2host_term\f1 to "\\n".
- .sp 0.5v
- If more than one means of specifying a host file column length
- is used (such as a terminator and a length prefix,
- or a terminator and a maximum column length), \f2bcp\f1 will
- look at all of them and use the one that results in the shortest amount
- of data being copied.
- .Pi host_termlen
- The length, in bytes, of the terminator sequence to be used
- for this column. To avoid using a terminator, set this value
- to -1.
- .Pi table_colnum
- The corresponding column in the database table. If this
- value is 0, this column will \f2not\f1 be copied. The
- first column is column 1.
- .in -.375i
- .Re
- .br
- SUCCEED or FAIL.
- .Sa
- bcp_batch,
- bcp_bind,
- bcp_collen,
- bcp_colptr,
- bcp_columns,
- bcp_control,
- bcp_done,
- bcp_exec,
- bcp_init,
- bcp_sendrow
- .mc
-